<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/16 0016
 * Time: 下午 8:29
 */
namespace App\Http\Controllers\v1;
use App\Members;
use Illuminate\Http\Request;
use Laravel\Lumen\Routing\Controller as BaseController;
class MemberController extends BaseController
{
    //添加
    public function add(Request $request)
    {

        if($request)
        {
            $member_obj  =  new Members();
            $member_obj->username   =   $request->username;
            $member_obj->alias      =   $request->alias;
            $member_obj->open_id    =   $request->open_id;
            $member_obj->picture    =   $request->picture;
            $member_obj->level      =   $request->level;
            $member_obj->create_at      =   time();
            $member_obj->update_at      =   time();
            if($member_obj->save())
            {
                return response()->json(array('status'=>1),200);
            };

            return response()->json(array('status'=>0),200);

        }

    }

    public function get_data($member_id)
    {
       $members =   Members::find($member_id);
        if($members)
        {
            return response()->json($members,200);
        }else
        {
            return response()->json((object)array(),200);
        }

    }


}